(function(){"use strict";BX.namespace("BX.Grid");BX.Grid.Rows=function(t){this.parent=null;this.rows=null;this.headChild=null;this.bodyChild=null;this.footChild=null;this.init(t)};BX.Grid.Rows.prototype={init:function(t){this.parent=t},reset:function(){this.rows=null;this.headChild=null;this.bodyChild=null;this.footChild=null},enableDragAndDrop:function(){this.parent.arParams["ALLOW_ROWS_SORT"]=true;if(!(this.parent.getRowsSortable()instanceof BX.Grid.RowsSortable)){this.parent.rowsSortable=new BX.Grid.RowsSortable(this.parent)}},disableDragAndDrop:function(){this.parent.arParams["ALLOW_ROWS_SORT"]=false;if(this.parent.getRowsSortable()instanceof BX.Grid.RowsSortable){this.parent.getRowsSortable().destroy();this.parent.rowsSortable=null}},getFootLastChild:function(){return this.getLast(this.getFootChild())},getFootFirstChild:function(){return this.getFirst(this.getFootChild())},getBodyLastChild:function(){return this.getLast(this.getBodyChild())},getBodyFirstChild:function(){return this.getFirst(this.getBodyChild())},getHeadLastChild:function(){return this.getLast(this.getHeadChild())},getHeadFirstChild:function(){return this.getFirst(this.getHeadChild())},getEditSelectedValues:function(){var t=this.getSelected();var e={};t.forEach(function(t){e[t.getId()]=t.editGetValues()});return e},getSelectedIds:function(){return this.getSelected().map(function(t){return t.getId()})},initSelected:function(){var t=this.getSelected();if(BX.type.isArray(t)&&t.length){t.forEach(function(t){t.initSelect()});this.parent.enableActionsPanel()}},editSelected:function(){this.getSelected().forEach(function(t){t.edit()});BX.onCustomEvent(window,"Grid::thereEditedRows",[])},editSelectedCancel:function(){this.getSelected().forEach(function(t){t.editCancel()});BX.onCustomEvent(window,"Grid::noEditedRows",[])},isSelected:function(){return this.getBodyChild().some(function(t){return t.isShown()&&t.isSelected()})},isAllSelected:function(){return!this.getBodyChild().filter(function(t){return!!t.getCheckbox()}).some(function(t){return!t.isSelected()})},getParent:function(){return this.parent},getCountSelected:function(){var t;try{t=this.getSelected().filter(function(t){return!t.isNotCount()&&t.isShown()}).length}catch(e){t=0}return t},getCountDisplayed:function(){var t;try{t=this.getBodyChild().filter(function(t){return t.isShown()&&!t.isNotCount()}).length}catch(e){t=0}return t},addRows:function(t){var e=BX.findChild(this.getParent().getTable(),{tag:"TBODY"},true,false);t.forEach(function(t){e.appendChild(t)})},getRows:function(){var t;var e=this;if(!this.rows){t=[].slice.call(this.getParent().getTable().querySelectorAll("tr[data-id], thead > tr"));this.rows=t.map(function(t){return new BX.Grid.Row(e.parent,t)})}return this.rows},getSelected:function(){return this.getBodyChild().filter(function(t){return t.isShown()&&t.isSelected()})},normalizeNode:function(t){if(!BX.hasClass(t,this.getParent().settings.get("classBodyRow"))){t=BX.findParent(t,{className:this.getParent().settings.get("classBodyRow")},true,false)}return t},getById:function(t){t=t.toString();var e=this.getBodyChild();var n=e.filter(function(e){return e.getId()===t});return n.length===1?n[0]:null},get:function(t){var e=null;var n;if(BX.type.isDomNode(t)){t=this.normalizeNode(t);n=this.getRows().filter(function(e){return t===e.getNode()});if(n.length){e=n[0]}}return e},getLast:function(t){var e;try{e=t[t.length-1]}catch(t){e=null}return e},getFirst:function(t){var e;try{e=t[0]}catch(t){e=null}return e},getHeadChild:function(){this.headChild=this.headChild||this.getRows().filter(function(t){return t.isHeadChild()});return this.headChild},getBodyChild:function(){this.bodyChild=this.bodyChild||this.getRows().filter(function(t){return t.isBodyChild()});return this.bodyChild},getFootChild:function(){this.footChild=this.footChild||this.getRows().filter(function(t){return t.isFootChild()});return this.footChild},selectAll:function(){this.getRows().map(function(t){t.isShown()&&t.select()})},unselectAll:function(){this.getRows().map(function(t){t.unselect()})},getByIndex:function(t){var e=this.getBodyChild().filter(function(t){return t}).filter(function(e){return e.getNode().rowIndex===t});return e.length?e[0]:null},getRowsByParentId:function(t,e){var n=[];var i=this;if(!t){return n}t=t.toString();function r(t){i.getBodyChild().forEach(function(i){if(i.getParentId()===t){n.push(i);e&&r(i.getId())}},i)}r(t);return n},getRowsByGroupId:function(t){var e=[];var n=this;if(!t){return e}t=t.toString();function i(t){n.getBodyChild().forEach(function(n){if(n.getGroupId()===t&&!n.isCustom()){e.push(n)}},n)}i(t);return e},getExpandedRows:function(){return this.getRows().filter(function(t){return t.isShown()&&t.isExpand()})},getIdsExpandedRows:function(){return this.getExpandedRows().map(function(t){return t.getId()})},getIdsCollapsedGroups:function(){return this.getRows().filter(function(t){return t.isCustom()&&!t.isExpand()}).map(function(t){return t.getId()})},getSourceRows:function(){return BX.Grid.Utils.getBySelector(this.getParent().getTable(),[".main-grid-header > tr",".main-grid-header + tbody > tr"].join(", "))},getSourceBodyChild:function(){return this.getSourceRows().filter(function(t){return BX.Grid.Utils.closestParent(t).nodeName==="TBODY"})},getSourceHeadChild:function(){return this.getSourceRows().filter(function(t){return BX.Grid.Utils.closestParent(t).nodeName==="THEAD"})},getSourceFootChild:function(){return this.getSourceRows().filter(function(t){return BX.Grid.Utils.closestParent(t).nodeName==="TFOOT"})},hasEditable:function(){return this.getBodyChild().some(function(t){return t.isEdit()})}}})();
//# sourceMappingURL=rows.map.js